﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SuYuanSystem.Applications;
using SuYuanSystem.Domain;
using SuYuanSystem.WebApi.MedialRs.Commands.Slaughters;

namespace SuYuanSystem.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SlaughterController : ControllerBase
    {
        public SlaughterController(IMediator mediator)
        {
            Mediator = mediator;
        }


        public IMediator Mediator { get; }

        /// <summary>
        /// 中介者添加屠宰信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> SlaughterAdd(SlaughterCommands command)
        {
            return await Mediator.Send(command);
        }

        /// <summary>
        /// 中介这查询屠宰信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<Slaughter>> SlaughterQuery()
        {
            SlaughterQueryCommands command = new SlaughterQueryCommands();
            return await Mediator.Send(command);
        }
    }
}
